﻿#if defined(_WIN32)&&defined (_DEBUG)
#include "vld.h"
#include "crtdbg.h"
#endif

#include "array/Arrays.h"
#include "collection/PriorityQueue.hpp"
#include "lang/Exception.h"
#include "lang/String.h"
#include "lang/System.h"
#include "util/Random.h"
#include "net/IP4Address.h"
#include "net/Socket.h"
#include "net/InetSocketAddress.h"
#include "io/ByteArrayOutputStream.h"

using namespace yzrilyzr_collection;
using namespace yzrilyzr_lang;
using namespace yzrilyzr_util;
using namespace yzrilyzr_net;
using namespace yzrilyzr_io;
using namespace yzrilyzr_array;
using namespace std;


int main(){
	System::out.println("测试");
	System::out.println(StringFormat::format("%.1f",20.0f));
	String a="1";
	String b=a;
	b+="2";
	String c=b;
	c+="3";
	System::out.println(a);
	System::out.println(b);
	System::out.println(c);
	System::out.println(nullptr);
	ByteArray aa;
	System::out.println(aa);
	Socket socket;
	socket.connect(std::make_shared<InetSocketAddress>(IPAddress::parse("127.0.0.1"), 13597));
	auto inPtr=socket.getInputStream();
	auto outPtr=socket.getOutputStream();
	auto & in=*inPtr;
	auto & out=*outPtr;
	auto bts=String("GET / HTTP1.0\r\n\Host: localhost\r\n\r\n").getBytes();
	out.write(bts);
	out.flush();
	ByteArrayOutputStream baos;
	u_index i;
	ByteArray buf(10);
	while((i=in.read(buf)) != -1){
		baos.write(buf, 0, i);
		if(String(buf, 0, i, UTF8).contains("\r\n\r\n"))break;
	}
	System::out.println(baos);
	return 0;
}
